package com.sourcetrip.arraylist;


import com.sourcetrip.raw.model.Skill;
import com.sourcetrip.raw.model.Worker;

/**
 * @author: ZhouBert
 * @date: 2020/11/16
 * @description: 深拷贝
 */
public class DeepCopy {

	public static void main(String[] args) throws CloneNotSupportedException {
		Skill skill = new Skill("bull shit");
		Worker jack = new Worker("jack", skill);
		Worker cloneWorker = (Worker) jack.clone();

		//print 内容一致
		System.out.println("jack  = " + jack);
		System.out.println("clone = " + cloneWorker);
		//print location --内存地址不同
		System.out.println(jack == cloneWorker);

		System.out.println("======");

		//对 skill 和 name 进行修改
		skill.setName("holy shit");
		jack.setName("ma");

		//print 内容一方发生了更改，符合预期！
		System.out.println("jack  = " + jack);
		System.out.println("clone = " + cloneWorker);
	}
}
